<?php			
	require("clima/simplepie.inc");
	require("clima/simplepie_yahoo_weather.inc");
	require('clima/TranslatorPlugin.php');
	require("clima/weathercodes.php");

	function init($code){
		setlocale (LC_TIME,"spanish");
		$path = "http://weather.yahooapis.com/forecastrss?u=c&p=";
		$feed = new SimplePie();
		$feed->set_feed_url($path.$code);
		$feed->set_item_class('SimplePie_Item_YWeather');
		$feed->init();
		return $feed;
	}

	function fromFtoC($tempF) {
		return round($tempC = ($tempF - 32) /1.8);
	}

	function time2minuts($time) {
		$minuts = 0;
		$atime = explode(" ", $time);
		$ttime = explode(":", $atime[0]);
		if ((strtolower($atime[1]) == "pm") && ($ttime[0] != '12')) {
			$minuts = 12*60;
		}
		$minuts = $minuts + (int)$ttime[0]*60 + (int)$ttime[1];
		return $minuts;
	}

	$feed = init('ARBA7414');
	$weather = $feed->get_item(0);
	if ($weather == null)
		return;
	$fore = $weather->get_forecasts();
	$unit = $weather->get_units_temp();
	$ampm = "n";
	$icon = $weather->get_condition_code();
	$curday = 2*60 + time2minuts(date("g:i a"));
	$iniday = time2minuts($weather->get_sunrise());
	$endday = time2minuts($weather->get_sunset());
	if ($curday > $iniday && $curday < $endday ) {
		$ampm = "d";
	}
?>

	<div class="span-5 last">
		<div class="sidebar sidebar-right">
            <?php if ($weather->get_temperature() != ""){?>
			<table class="weather" style="background:url('<?php bloginfo('template_url'); ?>/images/weather/s/<?php echo $icon?><?php echo $ampm?>.gif') no-repeat 0px -10px; height: 85px; width: 180px;">
				<tr>
					<td class="info" valign="top" style="text-align: right;">
						<span class="temp"><?php echo $weather->get_temperature() ?> &deg;C</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br/>
						<span class="fore">Min. <?php echo $fore[0]->get_low() ?>&deg;C&nbsp;&nbsp;Max. <?php echo $fore[0]->get_high()?>&deg;C</span><br/>
						<?php if ($weather->get_humidity() != ""){?>
							<span class="fore">Hum. <?php echo $weather->get_humidity() ?>%</span>&nbsp;&nbsp;
						<?php } ?>
						<?php if ($weather->get_visibility() != ""){?>
							<span class="fore">Visibil. <?php echo $weather->get_visibility() ?>Km</span>
						<?php } 
						$code =$weather->get_condition_code();
						?>
						<br/>
						<span class="fore"><b><?php echo htmlentities(TranslatorPlugin::code2Condition($code));?></b></span>
					</td>			
				</tr>
			</table>
			<?php } ?>
			<div style="background-color:yellow;height:125px;padding:5px;border:2px solid #E0E01F">
				<p align="left" style="margin-bottom:2px">
					<img style="float:left;margin-right:5px" src="<?php bloginfo('template_url'); ?>/images/phone.png" width="55px" />
					<span style="font-size:15px;font-weight:bold;color:#333;font-family:calibri">
						<?php echo utf8_encode('Gu&iacute;a Telef&oacute;nica de Laprida')?>
					</span>
				</p>
				<div style="margin:8px;text-align:center;float: left" >
					<form action="http://www.lapridenses.com.ar/guia/" method="POST" id="searchForm">
						<input type="text" size="20" name="name1" id="name1" value="Nombre" style="margin-bottom:6px;">
						<a href="guia" style="color:black">Avanzada</a>
						<input type="submit" value="Buscar">
						
					</form> 
				</div>
			</div>
			<div style="clear:both"></div>
			<br>
			<h2 class="widgettitle">Buscar</h2>
			<?php $search_text = empty($_GET['s']) ? "Texto a buscar" : get_search_query(); ?> 
			<div style="margin-top:7px" id="search">
				<form method="get" id="searchform" action="<?php bloginfo('home'); ?>/"> 
					<input type="text" value="<?php echo $search_text; ?>" 
						name="s" id="s"  onblur="if (this.value == '')  {this.value = '<?php echo $search_text; ?>';}"  
						onfocus="if (this.value == '<?php echo $search_text; ?>') {this.value = '';}" />
					<input type="image" src="<?php bloginfo('template_url'); ?>/images/search.gif" style="border:0; vertical-align: top;" /> 
				</form>
			</div>
			<br>
			<a href="http://www.radiolaprida.com" target="_blank"><img src="<?php bloginfo('template_url'); ?>/images/logoz.png" width="150px" style="margin-left:10px;"><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Escuch&aacute; la Z98 en vivo!&nbsp;&nbsp;&nbsp;&nbsp;</a><br><br>
			<div class="sidebaradbox">
    			<?php sidebar_ads_125(); ?>
    		</div>
			<ul>
				<?php 
						if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Right Sidebar') ) : ?>
					
					<li id="tag_cloud"><h2>Tags</h2>
                        <div><?php wp_tag_cloud('largest=16&format=flat&number=20'); ?></div>
						
					</li>
					
					<li><h2>Archives</h2>
						<ul>
						<?php wp_get_archives('type=monthly'); ?>
						</ul>
					</li>
					
					<li> 
						<h2>Calendar</h2>
						<?php get_calendar(); ?> 
					</li>
					<?php wp_list_bookmarks(); ?>
						
				<li><h2>Meta</h2>
					<ul>
						<?php wp_register(); ?>
						<li><?php wp_loginout(); ?></li>
						<li><a href="http://gmpg.org/xfn/"><abbr title="XHTML Friends Network">XFN</abbr></a></li>
						<li><a href="http://wordpress.org/" title="Powered by WordPress, state-of-the-art semantic personal publishing platform.">WordPress</a></li>
						<?php wp_meta(); ?>
					</ul>
					</li>
	
				<?php endif; ?>
			</ul>
		<?php if(get_theme_option('ad_sidebar2_bottom') != '') {
		?>
		<div  class="sidebaradbox">
			
		</div>
		<div  id="sidebaradbox3">
			
		</div>
		<?php
		}
		?>
		</div>
		
	</div>
